﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class ChiTiet : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnDat_Click(object sender, EventArgs e)
    {
            string id = Request.QueryString["MaXe"];
        //Session["gia"] = TextBox1.Text;
        //    Response.Redirect("DatHang.aspx?id=" + aa + "&sl=" + txtSoLuong.Text);
            
            DataTable tb_giohang;
            if (Session["giohang"] == null)
            {
                tb_giohang = new DataTable();
                tb_giohang.Columns.Add("MAXE");
                tb_giohang.Columns.Add("TENXE");
                tb_giohang.Columns.Add("SOLUONG");
                tb_giohang.Columns.Add("GIABAN");
                tb_giohang.Columns.Add("TONGTIEN");                
            }
            else
            {
                tb_giohang = (DataTable)Session["giohang"];
            }
            if (tb_giohang != null)
            {
                // mamh = Request.QueryString.Get("MaMH");
                //string sql = "select * from View_1 where MaMH='" + mamh + "'";
                //con.Moketnoi();
                //tb = con.Bang(sql);
                OTOWeb.DataOut dto = new OTOWeb.DataOut();
                DataTable tb = dto.Web_LoadSanPhamChiTiet(id).Tables[0];
                DataRow row;
                row = tb_giohang.NewRow();
                row["MAXE"] = tb.Rows[0]["MAXE"].ToString();
                row["TENXE"] = tb.Rows[0]["TENXE"].ToString();
                row["SOLUONG"] = txtSoLuong.Text;
                row["GIABAN"] = Convert.ToDecimal(tb.Rows[0]["GIABAN"]).ToString("0,0.0");
                row["TONGTIEN"] = (Convert.ToDecimal(tb.Rows[0]["GIABAN"]) * Convert.ToInt32(txtSoLuong.Text.Trim())).ToString("0,0.0");               
                tb_giohang.Rows.Add(row);
                Session["giohang"] = tb_giohang;
                Response.Redirect("Default.aspx");
                // con.Dongketnoi();
            }
    }
}